export const editMixin = {
  data() {
    return {
      //弹框标题
      textMap: {
        update: "编辑",
        create: "添加",
      },
      //数据校验规则
      rules: {}
    };
  },
  props: {
    //弹框显示
    visible: {
      type: Boolean,
      default: false
    },
    //弹框状态
    dialogStatus: {
      type: String,
      default: ""
    },
    //表单数据
    form: {
      type: Object,
      default: {
        id: undefined,
      }
    },
  },
  methods: {
    //提交表单
    submit() {
      this.$refs['form'].validate(valid => {
        if (!valid) return;
        this.callSave(this.form).then((res) => {
          this.form.id = res.data.id;
          this.$emit('success');
          this.$notify({
            title: "成功",
            message: "保存 成功",
            type: "成功",
            duration: 2000,
          });
        });
      })
    },
    //弹框关闭前置
    beforeClose() {
      this.$emit('update:visible', false); // 直接修改父组件的属性
    }
  }
};
